﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


class FindSentencesByGivvenWord
{
    static int returnStartIndexOfSentence(string text, int startIndex)
    {
        int result = new int();
        for (int counter = startIndex; counter >= 0; counter--)
        {
             
            if (char.IsUpper(text[counter]))
            {
                result = counter;
                break;
                //Console.WriteLine(counter);
            }
        }
        return result;
    }

    static int returnEndIndexOfSentence(string text, int startIndex)
    {
        int result = new int();
        for (int counter = startIndex; counter < text.Length; counter++)
        {
            if (text[counter] == '.')
            {
                result = ++counter;
                break;
                //Console.WriteLine(counter);
            }
        }
        return result;
    }

    static void Main(string[] args)
    {
        string inputText = Console.ReadLine();
        inputText = inputText.Trim();
        string searchString = Console.ReadLine();
        const char space = ' ';
        searchString = space + searchString + space;

        for (int index = 0; index < inputText.Length; index++)
        {
            int indexFount = inputText.IndexOf(searchString, index);
            if (indexFount != -1)
            {
                //if fount , print the result
                int sentenceStartIndex = returnStartIndexOfSentence(inputText, indexFount);
                int sentenceEndIndex = returnEndIndexOfSentence(inputText, indexFount);
                Console.WriteLine(inputText.Substring(sentenceStartIndex, sentenceEndIndex-sentenceStartIndex));

                // set the index right after the current index, to avoid double fount elementsb
                index = sentenceEndIndex;
            }
        }
    }
}